﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;

namespace Nova_DAL
{
    public class TPosState
    {
        string strSQL = "";
        DataSet ds = null;
        DbHelper dbHelper = new DbHelper();
        DbCommand cmd = null;

        ///<summary>
        ///获取货位状态对应图
        ///</summary>
        ///<param name="sQL">SQL</param>
        ///<returns>返回string</returnss>
        ///Writer：[王成友]
        ///Create Date： [2010-7-1]
        ///</summary>
        public string strPosImg(string PosID)
        {
            string strPosImg = "";
            try
            {
                strSQL = "select PosImg from TPosState where PosID='" + PosID + "'";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                ds = dbHelper.ExecuteDataSet(cmd);
                strPosImg = ds.Tables[0].Rows[0]["PosImg"].ToString();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return strPosImg;
        }

        ///<summary>
        ///获取货位状态信息
        ///</summary>
        ///<param name="sQL">SQL</param>
        ///<returns>返回dataset</returnss>
        ///Writer：[王成友]
        ///Create Date： [2010-7-1]
        ///</summary>
        public DataSet DataListPosState()
        {
            try
            {
                strSQL = "select PosID,PID,PosImg+PosContent as ImgC from TPosState order by PID";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                ds = dbHelper.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return ds;
        }

        ///<summary>
        ///获取货位状态对应数字
        ///</summary>
        ///<param name="sQL">SQL</param>
        ///<returns>返回string</returnss>
        ///Writer：[王成友]
        ///Create Date： [2010-7-1]
        ///</summary>
        public int intPosID(string PosImg)
        {
            int iPosID = 0;
            try
            {
                strSQL = "select PosID from TPosState where PosImg='" + PosImg + "'";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                ds = dbHelper.ExecuteDataSet(cmd);
                iPosID = Convert.ToInt32(ds.Tables[0].Rows[0]["PosID"].ToString());
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return iPosID;
        }
    }
}
